if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetCOIEMailTemplate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetCOIEMailTemplate]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

/******************************************************************
* Name:			GetCOIEMailTemplate
* Purpose:		Retrieves the email template with the specified type
*
* PARAMETERS
* Name    					Description					
* -------------  				-------------------------------------------
* 			
******************************************************************/

CREATE Procedure [dbo].[GetCOIEMailTemplate] 
@type VARCHAR(50)
AS
BEGIN

	SET NOCOUNT ON

	Select	Id,
		Type,
		RefCode.RefMeaning as TypeMeaning,
		BodyText
	FROM COIEMailTemplate LEFT JOIN RefCode ON COIEMailTemplate.Type = RefCode.RefCode
	WHERE type = @type
	ORDER BY TypeMeaning
	
END


GO

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF  